﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NNTH.Data
{
    public partial class PhongHoc : System.ComponentModel.IDataErrorInfo
    {
        public bool Chon { get; set; }
        public string Error
        {
            get
            {
                if (this.EntityState == System.Data.EntityState.Added || this.EntityState == System.Data.EntityState.Modified)
                {
                    StringBuilder sb = new StringBuilder();
                    if (!String.IsNullOrWhiteSpace(this["MaPhong"]))
                        sb.AppendLine(this["MaPhong"]);

                    if (!String.IsNullOrWhiteSpace(this["TenPhong"]))
                        sb.AppendLine(this["TenPhong"]);

                    if (!String.IsNullOrWhiteSpace(this["SucChua"]))
                        sb.AppendLine(this["SucChua"]);

                    string errors = sb.ToString();
                    return !String.IsNullOrEmpty(errors) ? errors : String.Empty;
                }
                else
                {
                    return String.Empty;
                }
            }
        }

        public string this[string columnName]
        {
            get
            {
                if (this.EntityState == System.Data.EntityState.Added || this.EntityState == System.Data.EntityState.Modified)
                {
                    switch (columnName)
                    {
                        case "MaPhong":
                            return String.IsNullOrWhiteSpace(this.MaPhong) ? "Chưa nhập mã phòng!" : String.Empty;
                        case "TenPhong":
                            return String.IsNullOrWhiteSpace(this.TenPhong) ? "Chưa nhập tên phòng!" : String.Empty;
                        case "SucChua":
                            return ((this.SucChua <= 0) || (this.SucChua > 255)) ? "Sức chứa không hợp lệ" : String.Empty;
                        default:
                            return String.Empty;
                    }
                }
                else
                {
                    return String.Empty;
                }
            }
        }
    }
}
